package cn.com.dhc.danlu.widget.home;

import android.view.View;

import java.util.Calendar;

/**
 * author: 李一方(<a href="mailto:liyifang@danlu.com">liyifang@danlu.com</a>)<br/>
 * version: 1.0.0<br/>
 * since: 2016-08-04 15:24<br/>
 *
 * <p>
 * 防止重复点击的监听器
 * </p>
 */
abstract class NoRepeatClickListener implements View.OnClickListener {
    private static final int MIN_CLICK_DELAY_TIME = 500;
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoRepeatClick(v);
        }
    }

    protected abstract void onNoRepeatClick(View v);
}